<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="com.demo.main.utils.CommonUtil" %>
<%@ page import="java.util.List" %>
<%@ page import="com.demo.main.vo.BorrowingVo" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="zh-CN">
<head>
    <title>留言求书</title>
    <link rel="stylesheet" href="/resources/css/index.css">
    <link rel="stylesheet" href="/resources/css/boots.css">
    <link rel="stylesheet" href="/resources/css/boot.css">
    <style>
        .main h1 {
               margin-top: 20px;
               margin-bottom: 10px;
           }

        .main form {
            margin-top: 20px;
        }

        .main label {
            font-weight: bold;
        }


        .container input[type="text"],
        .container textarea {
            width: 100%;
            padding: 5px;
            border-radius: 3px;
            border: 1px solid #ccc;
        }

        .main button[type="submit"] {
            padding: 8px 12px;
            background-color: #17a2b8;
            color: #fff;
            border: none;
            border-radius: 3px;
            cursor: pointer;
        }

    </style>
</head>
<body>
<%
    // public
    String username = (String) request.getSession().getAttribute("username");
    String identity = CommonUtil.getIdentity();
    List<String[]> permissions = (List<String[]>) request.getAttribute("permissions");
%>
<div class="container-fluid">
    <div class="top-nav">
        <div class="top-nav-container">
            <div class="left-box">
                <p>图书管理系统</p>
            </div>
            <div class="right-box">
                <p class="top-nav-username" style="margin-right: 10px">用户：<%=username%></p>
                <p class="top-nav-identity">类型：<%=identity.equals("user") ? "用户" : "管理员"%></p>
                <a href="/login?method=logout">
                    <button style="margin-left: 10px">退出登录</button>
                </a>
            </div>
        </div>
    </div>
    <div class="non-top-nav">
        <div class="sidebar">
            <ul class="sidebar-ul">
                <c:forEach var="item" items="<%=permissions%>">
                    <li><a href="${item[1]}">${item[0]}</a></li>
                </c:forEach>
            </ul>
        </div>
        <div class="main" style="margin-left: 0">
            <h1>留言板</h1>
            <%-- 留言表单 --%>
            <form action="${pageContext.request.contextPath}/SaveMessageServlet" method="post">
                <label for="username">用户名：</label>
                <input type="text" id="username" name="username" value="<%= username %>" readonly required><br><br>

                <label for="content">留言内容：</label><br>
                <textarea id="content" name="content" rows="4" cols="50" required></textarea><br><br>

                <button type="submit">提交留言</button>
            </form>
        </div>
    </div>
</div>
</body>
</html>
